package com.sc.outpatientsys.controller;

import com.sc.outpatientsys.entity.ClinicRegister;
import com.sc.outpatientsys.service.impl.ClinicRegisterService;
import com.sc.outpatientsys.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/clinicReg")
public class ClinicRegisterController extends BaseController{
    @Autowired
    private ClinicRegisterService clinicRegisterService;

    @RequestMapping("/insertCR")
    public JsonResult<Void> addClinicInfo(ClinicRegister clinicRegister){
        clinicRegisterService.insertCR(clinicRegister);
        return new JsonResult<>(OK);
    }
    @RequestMapping("/findById")
    public JsonResult<ClinicRegister> findByID(int cr_ID){
        ClinicRegister data = clinicRegisterService.findByID(cr_ID);
        return new JsonResult<>(OK,data);
    }
    @RequestMapping("/findByST_ID")
    public JsonResult<List<ClinicRegister>> findByST_ID(int st_ID){
        List<ClinicRegister> data = clinicRegisterService.findByST_ID(st_ID);
        return new JsonResult<>(OK,data);
    }
    @RequestMapping("/findByDC_ID")
    public JsonResult<List<ClinicRegister>> findByDC_ID(int dc_ID){
        List<ClinicRegister> data = clinicRegisterService.findByDC_ID(dc_ID);
        return new JsonResult<>(OK,data);
    }
    @RequestMapping("/findAll")
    public JsonResult<List<ClinicRegister>> findAll(){
        List<ClinicRegister> data = clinicRegisterService.findAll();
        return new JsonResult<>(OK,data);
    }

    @RequestMapping("/updateState")
    public JsonResult<Void> updateState(int cr_State, int cr_ID){
        clinicRegisterService.updateState(cr_State,cr_ID);
        return new JsonResult<>(OK);
    }

    //某个医生一天的看诊数
    @RequestMapping("/dc_count_everyday")
    public JsonResult<List<Map>> DC_Count_EveryDay(int dc_ID){
        List<Map> data = clinicRegisterService.statistic_DC_Count_EveryDay(dc_ID);
        return new JsonResult<>(OK,data);
    }
    //每个学生的看诊次数
    @RequestMapping("/st_count")
    public JsonResult<List<Map>> ST_Count(){
        List<Map> data = clinicRegisterService.statistic_ST_Count();
        return new JsonResult<>(OK,data);
    }
    //指定时间内发生的门诊信息
    @RequestMapping("/dc_count_bytime")
    public JsonResult<List<Map>> DC_Count_ByTimeSc(String start,String end){
        List<Map> data = clinicRegisterService.statistic_DC_Count_ByTimeSc(start, end);
        return new JsonResult<>(OK,data);
    }

    //通过医生ID和时间查看编号
    @RequestMapping("/dc_id_time")
    public JsonResult<List<ClinicRegister>> DC_ID_TIME(int dc_ID,String time){
        List<ClinicRegister> data = clinicRegisterService.statistic_DC_ID_TIME(dc_ID, time);
        return new JsonResult<>(OK,data);
    }
}
